package com.betterwood.dragon.service;

import java.util.List;

import com.betterwood.dragon.dao.ProductDao;

import com.betterwood.dragon.entity.Product;
import com.betterwood.dragon.entity.dto.ProductQuery;

import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;

@Service(value = "productService")
@RequiredArgsConstructor
public class ProductService {
    private final ProductDao productDao;

    public Product insert(Product record) {
        return productDao.save(record);
    }

    public Product save(Product record) {
        return productDao.save(record);
    }

    public Product getByPartnerNo(String partnerCode) {
        return productDao.getByProductNo(partnerCode);
    }

    // public Record insert(Record record) {
    // return recordDao.save(record);
    // }

    public List<Product> findAll() {
        return productDao.findAll();
    }

    public List<Product> findByQuery(Product product) {
        return productDao.listByQuery(product);
    }

    // public List<Site> findAll() {
    // return siteDao.findAll();
    // }

    public Product findById(String productId) {
        return productDao.getOneById(productId);
    }

    public List<Product> listByQuery(Product query) {
        return productDao.listByQuery(query);
    }

    public void flipStatus(String id, Integer status) {
        Product p = productDao.getOneById(id);
        p.setStatus(status);
        productDao.save(p);
    }

    // public Site save(Site site) {
    // return siteDao.save(site);
    // }

    // public Keyword findById(String id) {
    // return keywordDao.getOneById(id);
    // }
}